#include<bits/stdc++.h>
using namespace std;
struct Node{
	int x , y;
};
stack<Node>stk;
int g[110][110] , vis[110][110];
int n , m , ans;
int dx[4] = {-1 , 0 , 1 , 0};
int dy[4] = {0 , 1 , 0 , -1};
int solve(int a , int b){
	int ret = 0;
	while(stk.size()){
		stk.pop();
	}
	Node st = {a , b};
	stk.push(st);
	vis[a][b] = 1;
	ret++;
	while(stk.size()){
		Node pos = stk.top();
		stk.pop();
		for(int i = 0 ; i < 4 ; i++){
			int xx = pos.x + dx[i];
			int yy = pos.y + dy[i];
			if(g[xx][yy] == 1 && vis[xx][yy] == 0){
				Node new_pos = {xx , yy};
				stk.push(new_pos);
				vis[xx][yy] = 1;
				ret++;
			}
		}
	}
	return ret;
}
int main(){
	freopen("area.in" , "r" , stdin);
	freopen("area.out" , "w" , stdout);
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cin >> g[i][j];
		}
	}
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			if(g[i][j] == 1 && vis[i][j] == 0){
				ans = max(ans , solve(i , j));
			}
		}
	}
	cout << ans << endl;
	return 0;
}
